package com.woniu.controller;

import com.woniu.dto.CreatePrescriptionRequestDTO;
import com.woniu.service.DrugPrescriptionService;
import com.woniu.utils.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;

@RestController
@RequestMapping("/api/prescription")
public class PrescriptionController {
    @Resource
    private DrugPrescriptionService drugPrescriptionService;

    @PostMapping("/create")
    public ResponseUtil createPrescription(@RequestBody CreatePrescriptionRequestDTO request) throws ParseException, InterruptedException {
        return drugPrescriptionService.createPrescription(request);
    }
    @GetMapping("/history/{patientId}")
    public ResponseUtil getHistory(@PathVariable Integer patientId) {
        return drugPrescriptionService.getPrescriptionHistory(patientId);
    }
}
